#### Generate Figure: Unconditional Conjoint AMCE ####

fig2_dat = import(here("data","fig2_dat.rds")) |> fix_healthcare()

# Max/Min effect
fig2_dat$label[which.max(fig2_dat$effect)]; max(fig2_dat$effect)
fig2_dat$label[which.min(fig2_dat$effect)]; min(fig2_dat$effect)

# Plot
fig_cjoint_uc = plot_conjoint(conjoint = fig2_dat,
                     lab = policies, 
                     weights = dta_grp$demog_weight,
                     use="all",
                     title=NULL,
                     grouped_data=FALSE,
                     is_result = T)

print(fig_cjoint_uc)

ggsave(here("figures","figure_2.png"), fig_cjoint_uc,
       dpi = 600, units = "in", width = 6, height = 9)

ccat("See 'figure_2.png' for Figure 2 output")
ccat(paste0("Gun background check effect: ", fig2_dat$effect[fig2_dat$condition == "guns_bg"] |> round(2)))
ccat(paste0("Max effect: ", fig2_dat$condition[which.max(abs(fig2_dat$effect))], " (",
            max(abs(fig2_dat$effect)) |> round(2),")"))

